package fantasyfootball.data.entities;

import java.io.Serializable;
import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * Class: 605.441 
 * Group: Richard Koretke, Kay Jantharasorn, Israel Rivera.
 * 
 * @author Israel Rivera
 * 
 */
@Entity(name="FantasyTransaction")
public class FantasyTransaction implements Serializable{

	private static final long serialVersionUID = 3703936104884588928L;
	
	private Integer transactionID;
	private FantasyTeam fantasyTeam;
	private NFLPlayer nflPlayer;
	private Calendar date;
	private String transactionType;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="TransactionID", nullable=false)
	public Integer getTransactionID() {
		return transactionID;
	}
	
	public void setTransactionID(Integer transactionID) {
		this.transactionID = transactionID;
	}
	
	@JoinColumn(name="TeamName", nullable=false)
	@ManyToOne(fetch=FetchType.EAGER, optional=false)
	public FantasyTeam getFantasyTeam() {
		return fantasyTeam;
	}
	
	public void setFantasyTeam(FantasyTeam fantasyTeam) {
		this.fantasyTeam = fantasyTeam;
	}
	
	@JoinColumn(name="PlayerID", nullable=false)
	@ManyToOne(fetch=FetchType.EAGER, optional=false)
	public NFLPlayer getNflPlayer() {
		return nflPlayer;
	}
	
	public void setNflPlayer(NFLPlayer nflPlayer) {
		this.nflPlayer = nflPlayer;
	}
	
	@Column(name="ActionDate", nullable=false)
	public Calendar getDate() {
		return date;
	}
	
	public void setDate(Calendar date) {
		this.date = date;
	}
	
	@Column(name="TransactionType", nullable=false)
	public String getTransactionType() {
		return transactionType;
	}
	
	public void setTransactionType(String transactionType) {
		this.transactionType = transactionType;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((transactionID == null) ? 0 : transactionID.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FantasyTransaction other = (FantasyTransaction) obj;
		if (transactionID == null) {
			if (other.transactionID != null)
				return false;
		} else if (!transactionID.equals(other.transactionID))
			return false;
		return true;
	}
}